<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>管理员入口</title>
    <link rel="stylesheet" type="text/css" href="../../static/admin/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="../../static/admin/css/login2.css"/>
</head>

<body>
<div class="m-login-bg">
    <div class="m-login">
        <h3>管理员登录</h3>
        <div class="m-login-warp">
            <form class="layui-form" >
                <div class="layui-form-item">
                    <input type="text" name="yonghuming" required lay-verify="required" placeholder="用户名"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <input type="password" name="mima" required lay-verify="required" placeholder="密码"
                           autocomplete="off" class="layui-input">
                </div>
                <div id="ms" class="layui-form-mid layui-word-aux" style="color: red"></div>
                <div class="layui-form-item m-login-btn">
                    <div class="layui-inline">
                        <button class="layui-btn" lay-submit lay-filter="loginForm">登录</button>
                    </div>
                    <div class="layui-inline">
                        <a type="button" href="../yuangong/yuangong-login.html" class="layui-btn layui-btn-primary">员工登录</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="../../static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script>
    layui.use(['jquery','form','layer'],function () {
        var form =layui.form(),
            layer = layui.layer,
            $ =layui.jquery;

        form.on('submit(loginForm)',function (data) {
            $.ajax({
                type:"POST",
                url:"/guanliyuan/login",
                data:{
                    "yonghuming": data.field.yonghuming,
                    "mima": data.field.mima,
                },
                dataType:"json",
                success:function (res) {
                    if (res.flag){
                        window.location.href="guanliyuan-main.html";
                    }else {
                        $("#ms").html(res.msg);
                    }
                }
            })
            return false;
        })
    })
</script>
</body>

</html>